<%@ page import="java.util.*,SiTuQingYou.vo.*,SiTuQingYou.util.*" language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%String path=request.getContextPath(); %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css" >
#div00
{

margin-top:50px;

}
ul
{
margin:0px;
padding:0px;
list-style:none;
}
#ulxx>li
{
float:left;
margin:10px;
}
#ulxx>li>ul>li
{
width:300px;
text-align: center;
margin:10px;
 
height:20px;
}
 
img
{
width:100%;
height:100%;

}
a
{
text-decoration: none;
}
#divs
 {
 margin-left:150px;
 width:930px;
 height:200px;
 
 margin-top:20px;
 }
#divleft
{
margin-left:10px;
float:left;
width:300px;
height:200px;
 
}
#divright
{
margin-left:10px;
float:left;
width:600px;
height:200px;
background-color:#ddd;
}
#title
{
text-align:center;
 
width:300px;
height:30px;
margin-left:100px;
}
#contentx
{
height:60px;
font-size:15px;
margin-top:10px;
 
width:500px;
display:-webkit-box;
-webkit-box-orient:vertical;
-webkit-line-clamp:3;
overflow:hidden;
text-overflow:ellipsis;/* 支持 IE */
 
}
#contentx>a
{
text-decoration: none;
}
#author a
{
text-decoration: none;
}
#title>a
{
text-decoration: none;
}

#author
{
margin-top:50px;
 
width:600px;
height:30px;
 
}
#divleft img
{
width:100%;
height:100%;
}
#more
{
margin-top:20px;
width:1000px;
text-align: right;
}
#author span
{
float:right;
margin-right:10px;
}
#imgg
{
width:300px;
height:200px;
}
.pager a{display:inline-block; width:40px;height:40px;background-color:gray;color:white;text-align:center;line-height:40px;border-radius:18px;text-decoration:none;}
	.pager a.cur{background-color:green;} 


</style>
  <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
<script type="text/javascript">
$(document).ready(load);
function load()
{
   $(document).ready(function(){
	   $("#d").css("background-color","red");
	   $("span[id=col]").click(function(){
		var id = $(this).attr("cid");
		  $.ajax(
				  {
					  url:"<%=path%>/MyCollectionServlet",
					  type:"post",
					  data:"method=checkStrategyCollectionServlet&id="+id,
					  success:function(mes){
						if(mes==2)
							{
							 location.href = "/SiTuQingYou/anotherLogReg/login.jsp";
							}
							if(mes==1)
						    	{
								$("#col").children().css("color","black");
						    	alert("取消收藏")
						    	}
						    if(mes==0)
					    	{
						    $("#col").children().css("color","red");
					    	alert("收藏成功")
					    	}	
							}
				  });
		   
	   });
	   
   });
}

 

</script>
 <!-- 点赞 -->
<script type="text/javascript">
$(document).ready(load);
function load()
{
   $(document).ready(function(){
	   $("span[id=lik]").click(function(){
		  var id=$(this).attr("cid");
		  var t=$(this);
		  var count=$(this).prev().html();
		  count=parseInt(count);
		  $.ajax(
				  {
					  url:"<%=path%>/MyCollectionServlet",
					  type:"post",
					  data:"method=checkStrategyLikeServlet&id="+id,
					  success:function(mes){
						  if(mes==2)
							{
							 location.href = "/SiTuQingYou/anotherLogReg/login.jsp";
							}
							if(mes==1)
						    	{
								count--;
								t.prev().html(count);
								t.children().css("color","black");
						    	 
						    	}
						    if(mes==0)
					    	{
						    count++;
						    t.prev().html(count);
						    t.children().css("color","red");
					    	}	
							}
				  });
		   
		   
	   });
	   
   });
}


</script>
<!-- 得出该攻略总赞数 -->
<script type="text/javascript">
$(document).ready(function(){
	 
	 var totals=$("span[id=total]");
	 var cids="";
		totals.each(function()
		{
		var cid=$(this).attr("cid");
		cids=cids+"&"+"cid="+cid;	
		});
	
	 $.ajax(
			  {
				  url:"<%=path%>/MyCollectionServlet",
				  type:"post",
				  data:"method=getManyToatalLike"+cids,
				  success:function(mes){
					   var str=mes;
					   str=str.substring(1);
					   var totalss=new Array();
					   totalss=str.split(",");
					   var i=0;
					   totals.each(function()
								{
								 $(this).html(totalss[i]);
								 i++;	
								});
					  
					  
						}
			  });
	
});
</script>
  
  



</head>
<body>
<jsp:include page="header.jsp"></jsp:include>
<jsp:include page="/StrategyServlet"><jsp:param value="getAllStrategy" name="method"/></jsp:include>

<%ArrayList<Strategy>strategys=(ArrayList<Strategy>)request.getAttribute("strategys");
Pager pager = (Pager) request.getAttribute("pager"); 
ArrayList<Scene>scenes=(ArrayList<Scene>)request.getAttribute("scenes");
%>

<div id="div00">

 
<%
for(Strategy str:strategys)
{
%><div id="divs">
		<div id="divleft"><a href="<%=path%>/index/strategyinformation.jsp?id=<%=str.getId()%>"><img src="<%=path%>/imagess/<%=str.getPhoto()%>"/></a></div>
		<div id="divright">
		<div id="title"><a href="<%=path%>/index/strategyinformation.jsp?id=<%=str.getId()%>"><h4><%=str.getTitle()%></h4>  </a></div>
		<div id="contentx"><a href="<%=path%>/index/strategyinformation.jsp?id=<%=str.getId()%>"><%=str.getContent() %></a></div>
		<div id="author">  <span>by <%=str.getUser().getUsernickname()%></span> 
		<span id="col"    cid="<%=str.getId()%>" ><a href="javascript:void(0)"  id="cccl"    cid="<%=str.getId()%>" >收藏</a></span>
		
		<span id="total" cid="<%=str.getId()%>">0</span>
		<span id="lik" cid="<%=str.getId()%>"><a href="script:void(0)">点赞</a></span>
		
		</div>
		</div>
		
		</div> <%  
}
%>
 
</div>
<div class="pager">
         <%
           for(int i=1;i<=pager.getPageCount();i++)
           {%>
              <a href="<%=path%>/index/strategy.jsp?pageNum=<%=i%>" class=<%=(i==pager.getPageNum()?"cur":"")%>><%=i%></a>
           
          <%}%>
                         共<%=pager.getPageCount() %>页   共<%=pager.getDataCount() %>记录 
</div>	
<jsp:include page="footer.jsp"></jsp:include>
</body>
</html>